package com.kimu.product_comment_service_provider.service;

import org.apache.dubbo.config.annotation.DubboService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kimu.product_comment_service_interface.entity.ProductComment;
import com.kimu.product_comment_service_interface.mapper.ProductCommentMapper;
import com.kimu.product_comment_service_interface.service.ProductCommentService;

@DubboService
public class ProductCommentServiceImpl implements ProductCommentService {

    private ProductCommentMapper productCommentMapper;

    public ProductCommentServiceImpl(ProductCommentMapper productCommentMapper) {
        this.productCommentMapper = productCommentMapper;
    }

    @Override
    public int createProductComment(ProductComment ProductComment) {
        int row = productCommentMapper.insert(ProductComment);
        return row;
    }

    @Override
    public ProductComment getProductCommentById(Long id) {
        ProductComment productComment = productCommentMapper.selectById(id);
        return productComment;
    }

    @Override
    public int updateProductComment(ProductComment productComment) {
        int row = productCommentMapper.updateById(productComment);
        return row;
    }

    @Override
    public int deleteProductCommentById(Long id) {
        int row = productCommentMapper.deleteById(id);
        return row;
    }

    @Override
    public IPage<ProductComment> getProductComments(Page<ProductComment> page) {
        IPage<ProductComment> result = productCommentMapper.selectProductCommentPage(page);
        return result;
    }
    
}
